package com.peas.platform.module.icims;

import org.junit.jupiter.api.Test;

import java.io.File;

public class JavalibTestCase {

    @Test
    public void cleanBpm() {
        clean("javalib_bpm");
    }

    @Test
    public void cleanDatasource() {
        clean("javalib_datasource");
    }

    @Test
    public void cleanRedission() {
        clean("javalib_redission");
    }

    @Test
    public void cleanShardingJDBC() {
        clean("javalib_shardingjdbc");
    }

    @Test
    public void cleanKafka() {
        clean("javalib_kafka");
    }

    @Test
    public void cleanRabbitmq() {
        clean("javalib_rabbitmq");
    }

    @Test
    public void cleanRocketmq() {
        clean("javalib_rocketmq");
    }

    @Test
    public void cleanMinio() {
        clean("javalib_minio");
    }

    @Test
    public void cleanElasticsearch() {
        clean("javalib_elasticsearch");
    }

    private void clean(String pkg) {
        String base = "javalib";
        String dir = "/Users/caizhaohui/Downloads/";
        File p1 = new File(dir + pkg);
        String lib = dir + base;
        File[] files = p1.listFiles();
        assert files != null;
        for (File file : files) {
            String name = file.getName();
            File jar = new File(lib + "/" + name);
            if (jar.exists()) {
                boolean bool = file.delete();
                System.out.println("delete:" + file.getAbsolutePath() + ",result:" + bool);
            }
        }
    }
}
